<script>
    import { getShoppingNum, getUserVipInfo, getUserInfo, getConfInfo, updateManager, shareLogin } from './util/commonFn'
    export default {
        globalData: {
            loginData: {
                encryptedData: '',
                iv: '',
                code: '',
                phone: '',
                version: '1.3.4'
            }
        },
        onLaunch: function(res) {
            getConfInfo().then(data=>{
                let version = '1.1.1';
                // 系统版本号
                uni.getSystemInfo({
                    success (res) {
                        console.log(res.model)
                        console.log(res.version)
                    }
                })
                let systemVersion = data.version;
                let firstUpdate = systemVersion.slice(0,1) < version.slice(0,1);
                let isUpdate = Number(version.replace(/[.]/g,"")) > Number(systemVersion.replace(/[.]/g,""));
                this.$store.commit('hidePart', isUpdate);

                let isMustUpdate = firstUpdate || (systemVersion.slice(0,1) === version.slice(0,1) && systemVersion.slice(2,3) < version.slice(2,3));
                console.log(isMustUpdate, systemVersion, isUpdate, version.replace(/[.]/g,""), systemVersion.replace(/[.]/g,""))
                if(isMustUpdate){ // 强制更新
                    updateManager(true);
                } else if(isUpdate){
                    updateManager(false); // 提醒更新
                } else {
                }
            });
		},
		onShow: function(res) {
            // that.$store.commit('vipCardNum', uni.getStorageSync('vipCardNum'));
            shareLogin(res)
            getShoppingNum();
            getUserVipInfo();
            getUserInfo();
            let that = this;
            that.$store.commit('login', uni.getStorageSync('login'));
            uni.getSetting({
                success: (data) => {
                    if (data.authSetting['scope.userInfo']) {
                        that.$store.commit('authorization', true);
                    } else {
                        //用户没有授权
                        that.$store.commit('authorization', false);
                    }
                }
            });
        },
        onHide: function() {
            console.log('App Hide');
        }
    }
</script>

<style>
    /*每个页面公共css */
    .blue-title,.blue-title6,.blue-title8,.yellow-title{
        position: relative;
    }
    .yellow-title::after {
        display: block;
        content: "";
        position: absolute;
        height: 29rpx;
        width: 6rpx;
        background:rgba(255,174,69,1);
        left: 0;
        top: 50%;
        transform: translateY(-50%);
    }
    .blue-title::after {
        display: block;
        content: "";
        position: absolute;
        height: 32rpx;
        width: 4rpx;
        background: rgba(43, 168, 252, 1);
        left: 0;
        top: 50%;
        transform: translateY(-50%);
    }
    .blue-title6::after {
        display: block;
        content: "";
        position: absolute;
        height: 29rpx;
        width: 6rpx;
        background: rgba(43, 168, 252, 1);
        left: 0;
        top: 50%;
        transform: translateY(-50%);
    }
    .blue-title8::after {
        display: block;
        content: "";
        position: absolute;
        height: 36rpx;
        width: 8rpx;
        background: rgba(43, 168, 252, 1);
        left: 0;
        top: 50%;
        transform: translateY(-50%);
    }
    /* //单行省略号 */
    .cl1 {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
        word-break: break-all;
        overflow: hidden;
    }

    /* //两行省略号 */
    .cl2 {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        word-break: break-all;
        overflow: hidden;
    }
</style>
